import unittest

from api.add_emp import emp_api
from common.py_05_tools import Tools_unitest


class TestEmp_curd(unittest.TestCase):

    def test01_add_emp(self):
        header = {"Authorization": "Bearer 241bc6f9-57ae-47c6-8d6a-302503fa3fd7"}
        json_data = {"username": "蜡笔大新",
                     "mobile": "13344229062",
                     "workNumber": "9527"}
        resp = emp_api.add_emp(header, json_data)
        print("添加员工", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, True, 10000, "操作成功")

    def test02_query_emp(self):
        user_id = "1452154658746269696"
        header = {"Authorization": "Bearer 241bc6f9-57ae-47c6-8d6a-302503fa3fd7"}
        resp = emp_api.query_emp(user_id, header)

        print("查询员工", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, True, 10000, "操作成功")

    def test3_modify_emp(self):
        user_id = "1452154658746269696"
        header = {"Authorization": "Bearer 241bc6f9-57ae-47c6-8d6a-302503fa3fd7"}
        json_data = {"username": "蜡笔老新"}
        resp = emp_api.modify_emp(user_id, header, json_data)

        print("修改员工", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, True, 10000, "操作成功")

    def test4_del_emp(self):
        user_id = "1452154658746269696"
        header = {"Authorization": "Bearer 241bc6f9-57ae-47c6-8d6a-302503fa3fd7"}

        resp = emp_api.del_emp(user_id, header)

        print("删除员工", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, True, 10000, "操作成功")
